package special;

public class LeeCode_lcp_33 {
    public static void main(String[] args) {
        System.out.println(storeWater(new int[]{1, 3}, new int[]{6, 8}));
    }
    private static int storeWater(int[] bucket, int[] vat) {
        int n = bucket.length, ans = Integer.MAX_VALUE, sum = 0, max = 0;
        for (int i : vat) {
            sum += i;
            max = Math.max(max, i);
        }
        if (sum == 0)
            return 0;
        for (int i = 1; i <= max && i < ans; i++) {
            int c = 0;
            for (int j = 0; j < n; j++) {
                c += Math.max((vat[j] + i - 1) / i - bucket[j], 0);
            }
            ans = Math.min(ans, c + i);
        }
        return ans;
    }
}
